import request from "@/utils/request";

//获取题库信息  /admin/exam/question
export function getQuestion(str) {
  return request({
    url: `/admin/exam/question?${str}`,
  });
}
// 获取学科下拉列表  /admin/subject/tree
export function getQuestionTree(str) {
  return request({
    url: "/admin/subject/tree",
  });
}
// 上架下架 /admin/exam/question/show
export function isShowQuestion(data) {
  return request({
    url: "/admin/exam/question/show",
    method: "post",
    data: {
      id: [data.id],
      show_state: data.show_state === 1 ? 2 : 1,
    },
  });
}
// 审核状态   /admin/exam/question/check
export function checkQuestion(data) {
  return request({
    url: "/admin/exam/question/check",
    method: "POST",
    data: {
      checklist: [
        {
          check_remarks: data.check_remarks,
          check_state: data.check_state === "通过" ? 2 : 3,
          id: data.id,
        },
      ],
    },
  });
}
// 删除  /admin/exam/question
export function delQuestion(id) {
  return request({
    url: `/admin/exam/question/${id}`,
    method: "DELETE",
  });
}
// 批量上架、下架操作
export function AllShowQuestion(id, type) {
  return request({
    url: "/admin/exam/question/show",
    method: "post",
    data: {
      id: id,
      show_state: type,
    },
  });
}
// 全部审核通过
export function AllCheckQuestion(data) {
  return request({
    url: "/admin/exam/question/check",
    method: "POST",
    data: {
      checklist: data,
    },
  });
}
// 新建试题功能 /admin/exam/question
export function AddQuestion(data) {
  return request({
    url: "/admin/exam/question",
    method: "POST",
    data,
  });
}
// 考试列表
export const getExamList = (params) => {
    return request({
        url: "/admin/exam/exam",
        method: "GET",
        params,
    });
};
// 考试单个
export const getExamInfo = (id) => {
    return request({
        url: "/admin/exam/exam/" + id,
        method: "GET",
    });
};
// 考试增加
export const addExam = (data) => {
    return request({
        url: "/admin/exam/exam",
        method: "POST",
        data,
    });
};
// 考试修改
export const editExam = (data) => {
    return request({
        url: "/admin/exam/exam/" + data.id,
        method: "PUT",
        data,
    });
};
// 考试删除
export const deleteExam = (id) => {
    return request({
        url: "/admin/exam/exam/" + id,
        method: "DELETE",
    });
};
// 推送班级
export const bindClass = (data) => {
    return request({
        url: "/admin/exam/exam/bindClass",
        method: "POST",
        data,
    });
};
//班级的列表
export const getClassList = (params) => {
    return request({
        url: "/admin/class/class",
        method: "GET",
        params,
    });
};
//试卷的列表
export const getPaperList = (params) => {
    return request({
        url: "/admin/exam/paper",
        method: "GET",
        params,
    });
};

// 获取单个试卷信息 不是试题
export const getPaperInfo = (id) => {
    return request({
        url: "/admin/exam/paper/" + id,
        method: "GET",
    });
};
// 试卷增加
export const addPaper = (data) => {
    return request({
        url: "/admin/exam/paper",
        method: "POST",
        data,
    });
};
// 试卷修改
export const editPaper = (data) => {
    return request({
        url: "/admin/exam/paper/" + data.id,
        method: "PUT",
        data,
    });
};
// 试卷删除
export const deletePaper = (id) => {
    return request({
        url: "/admin/exam/paper/" + id,
        method: "DELETE",
    });
};
// 试卷状态切换
export const changePaperStatus = (id, state) => {
    return request({
        url: `/admin/exam/paper/${id}/${state}`,
        method: "GET",
    });
};
// 获取单个试卷信息 不是试题
export const getSingleItem = (id) => {
    return request({
        url: "/admin/exam/question/" + id,
        method: "GET",
    });
};
export function xtClick(params) {
    return request({
        url: "/admin/exam/question",
        params,
    });
}
export function establish(data) {
    return request({
        url: "/admin/exam/paper",
        method: "POST",
        data,
    });
}
export function edit(id) {
    return request({
        url: `/admin/exam/paper/${id}`,
    });
}

export function editData(data) {
    return request({
        url: `/admin/exam/paper/${data.id}`,
        method: "PUT",
        data,
    });
}
